# -*- coding: utf-8 -*-
"""
Created on Tue Oct 17 22:21:11 2017

@author: Luther
"""
user_dict = {}
user_dict['admin'] = 'admin'

user = input('请输入用户名：')

while user == "":
    print('用户名不能为空，请重新输入！')
    user = input('请输入用户名：')

if user_dict.get(user) == None:
    create = input('该用户不存在！创建该用户请按回车，键入任意值退出')
    if create == '':
        password = input('请设置密码：')
        while password == '':
            print('密码不能为空，请重新输入！')
            password = input('请设置密码：')
        password2 = input('请再输入一遍：')
        while password != password2:
            password = input('输入不一致！请重新输入：')
            password2 = input('请再输入一遍：')
        user_dict[user] = password
        print('设置成功！')
        user = input('请输入用户名：')
        password = input('请输入密码：')
    else:
        print('Goodbye!')
else:
    create = ''
    password = input('请输入密码：')

if create == '':
    i = 5
    while ((user_dict[user] != password) & (i > 1)):
        i = i - 1
        password = input('密码错误，你还可以重新输入{}次：'.format(i))

    if user_dict[user] == password:
        print('登录成功！')
    else:
        print('登录失败！')
